﻿using System;
using Iesi.Collections.Generic;
using System.Collections.Generic;
namespace EntityModel
{
    public enum ProductType
    {
        Mobile = 0,
        Book = 1
    }

    public abstract class Product
    {
        public virtual int ProductID { get; set; }

        private ISet<Order> m_orders = null;
        public virtual ISet<Order> Orders
        {
            get
            {
                if (this.m_orders == null)
                {
                    this.m_orders = new HashedSet<Order>();
                }
                return this.m_orders;
            }
            set
            {
                this.m_orders = value;
            }
        }

        public virtual string Name { get; set; }

        public virtual float Price { get; set; }

        public virtual DateTime CreateTime { get; set; }

        public abstract ProductType Type { get; }
    }

    public class Order
    {
        public Order()
        {
            this.Products = new HashedSet<Product>();
        }

        public virtual int OrderID { get; set; }

        public virtual ISet<Product> Products { get; set; }

        public virtual float Price { get; set; }

        public virtual OrderState State { get; set; }

        public virtual DateTime CreateTime { get; set; }

        public virtual User User { get; set; }

        public virtual string Address { get; set; }

        public virtual string Zip { get; set; }

        public virtual string Coignee { get; set; }
    }

    public class MobileProduct : Product
    {
        public virtual string Brand { get; set; }

        public virtual string Number { get; set; }

        public override ProductType Type
        {
            get { return ProductType.Mobile; }
        }
    }

    public class BookProduct : Product
    {
        public virtual string Author { get; set; }

        public override ProductType Type
        {
            get { return ProductType.Book; }
        }
    }



    public enum OrderState
    {
        Created,
        Paied,
        Consignment,
        Complete,
    }
}
